package dao;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import model.User;
public class UserDao {
public User login(Connection con,User user) throws Exception{
	User resultUser=null;
	String sql="select * from user where userName=? and password=?";
	PreparedStatement pstmt=con.prepareStatement(sql);
	pstmt.setString(1,user.getUserName());
	pstmt.setString(2,user.getpassword());
	ResultSet rs=pstmt.executeQuery();
	if(rs.next()){
		resultUser=new User();
		resultUser.setUserName(rs.getString("userName"));
		resultUser.setpassword(rs.getString("password"));
	}
	return resultUser;	
}
}
